package jwdt.xadmin.added.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.added.bean.TLeadmail;
import jwdt.xadmin.added.service.LeadmailManageService;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/added")
public class LeadmailManageAction extends BaseAction {
	
	private LeadmailManageService leadmailManageService = (LeadmailManageService)app.getBean("leadmailManageService");
	
	@RequestMapping("/listLeadmail")
	public Page doListLeadmail(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TLeadmail obj = (TLeadmail)f.copy2Class(TLeadmail.class);
		return m.getWritePage(f, leadmailManageService.doList(pu, obj).toJson());
	}
	
	@RequestMapping("/addLeadmail")
	public Page doAddact(Form f, Module m) throws Exception {
		TLeadmail obj = (TLeadmail)f.copy2Class(TLeadmail.class);
		return m.getWritePage(f, leadmailManageService.doAddact(obj));
	}
	
	@RequestMapping("/ediTLeadmail")
	public Page doEditact(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		TLeadmail obj = (TLeadmail)f.copy2Class(TLeadmail.class);
		return m.getWritePage(f, leadmailManageService.doEditact(obj, id));
	}
	
	@RequestMapping("/delLeadmail")
	public Page doDel(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		return m.getWritePage(f, leadmailManageService.doDelact(id));
	}
	
	@RequestMapping("/shenheLeadmail")
	public Page doShenhe(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		String result = f.getString("result");
		return m.getWritePage(f, leadmailManageService.doUpdateState(id, result));
	}
	
	@RequestMapping("/leadmailWindow")
	public Page doLoad(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		f.add("obj", leadmailManageService.doLoad(id));
		return m.findPage("/xadmin/added/leadmailWindow");
	}
}
